from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from constant import USER, PASSWORD, IP, PORT, DATABASE


class DB():
    def __init__(self):
        db = "mysql+pymysql://" + USER + ":" + PASSWORD + "@" + IP + ":" + PORT + "/" + DATABASE
        engine = create_engine("mysql+pymysql://%s:%s@%s:%s/%s" % (USER, PASSWORD, IP, PORT, DATABASE))

        # 创建Session类
        Session = sessionmaker(bind=engine)

        # 创建实际的Session对象
        self.session = Session()
